
#import "AFShadowTextCell.h"

@implementation AFShadowTextCell

- (id)init {
	[super init];
	
	[self setShadowColor:[NSColor whiteColor]];
	
	[self setFont:[NSFont boldSystemFontOfSize:11]];
	[self setTextColor:[NSColor colorWithCalibratedRed:(80.0/255.0) green:(93.0/255.0) blue:(109.0/255.0) alpha:1.0]];
	
	[self setLineBreakMode:NSLineBreakByTruncatingTail];
	
	[self setDrawsBackground:NO];
	
	return self;
}

- (void)dealloc {
	[_shadowColor release];
	
	[super dealloc];
}

- (void)setShadowColor:(NSColor *)color {
	[color retain];
	[_shadowColor release];
	_shadowColor = color;
}

- (void)drawWithFrame:(NSRect)frame inView:(NSView *)view {
	[self drawInteriorWithFrame:frame inView:view];
}

- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view {
	NSShadow *shadow = nil;
	if (_shadowColor != nil) {
		[NSGraphicsContext saveGraphicsState]; 
		
		shadow = [[NSShadow alloc] init];
		[shadow setShadowOffset:NSMakeSize(0, -1)]; 
		[shadow setShadowBlurRadius:0.3]; 
		[shadow setShadowColor:_shadowColor];
		[shadow set];
	}
	
	[super drawInteriorWithFrame:NSInsetRect(frame, 0, (NSHeight(frame) - [self cellSizeForBounds:frame].height)/2.0) inView:view];
	
	if (_shadowColor != nil) {
		[NSGraphicsContext restoreGraphicsState];
		[shadow release];
	}
}

- (void)_drawHighlightWithFrame:(NSRect)frame inView:(NSView *)view {
	return;
}

@end
